package com.envoy.testsuite.mvc;

import java.util.EnumMap;

/**
 * Transfers data to and from the model.
 * @author Angus J. Goldsmith
 * @param <T> the type of enum to be used as a key.
 * @param <D> the type of enum to be used for data type.
 */
public class ModelTransferObject<T extends Enum<T>, D extends Enum<D>> {
  /**
   * The type of data being transfered.  Allows the model or the view to know
   * what to do with it.
   */
  private D dataType;

  /**
   * The data.
   */
  private EnumMap<T, String> data;

  /**
   * Constructor, sets up the fields.
   * @param iDataType the initial data type.
   * @param iData the initial data.
   */
  ModelTransferObject(final D iDataType,
      final EnumMap<T, String> iData) {
    dataType = iDataType;
    data = iData;
  }

  /**
   * Gets the data type.
   * @return the data type.
   */
  public final D getDataType() {
    return dataType;
  }

  /**
   * Gets the data.
   * @return the data.
   */
  public final EnumMap<T, String> getData() {
    return data;
  }

  /**
   * Gets a value from the data by a given key.
   * @param key the key.
   * @return the value.
   */
  public final String getValue(final T key) {
    return data.get(key);
  }
}
